package cs2340.quarterblack.wheresmystuff;

import android.app.PendingIntent;
import android.appwidget.AppWidgetManager;
import android.appwidget.AppWidgetProvider;
import android.content.Context;
import android.content.Intent;
import android.widget.RemoteViews;

public class AppWidget extends AppWidgetProvider {

	@Override
	public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
		
		RemoteViews remoteView = new RemoteViews(context.getPackageName(), R.layout.app_widget_layout);
		Intent intent = new Intent(context, CreateItem.class);
		intent.putExtra("userId", "bob");
		intent.putExtra("state", true);
		
		PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, 0);
		
		remoteView.setOnClickPendingIntent(R.id.widget_button, pendingIntent);
		
		appWidgetManager.updateAppWidget(appWidgetIds, remoteView);
	}
}
